

#include <dht11.h>

dht11 DHT11;

#define DHT11PIN 2

void setup()
{
  Serial.begin(9600);
  Serial.println("DHT11 TEST PROGRAM ");
  Serial.print("LIBRARY VERSION: ");
  Serial.println(DHT11LIB_VERSION);
}

void loop()
{
  int chk = DHT11.read(DHT11PIN);

  //Serial.print("Read sensor: ");
  switch (chk)
  {
    case DHTLIB_OK:
      //Serial.println("OK");
      break;
    case DHTLIB_ERROR_CHECKSUM:
      Serial.println("Checksum error");
      break;
    case DHTLIB_ERROR_TIMEOUT:
      Serial.println("Time out error");
      break;
    default:
      Serial.print("Unknown error ");
      Serial.println(chk);
      break;
  }

  Serial.print(" Humidity (%): ");
  Serial.print((float)DHT11.humidity, 2);

  Serial.print(" Temperature (oC): ");
  Serial.print((float)DHT11.temperature, 2);


  Serial.println("");
  delay(2000);
}
